package main

import "github.com/gin-gonic/gin"

func _html(context *gin.Context) {
	context.HTML(200, "index.html", gin.H{"username": "xxx"})
}
func main() {
	router := gin.Default()
	router.LoadHTMLGlob("templates/*")
	router.GET("/", func(context *gin.Context) {
		type userInfo struct {
			UserName string `json:"userName1"`
			Age      int    `json:"age1"`
			Password string `json:"-"` //不去json虚拟化
		}
		user := userInfo{
			UserName: "xxx",
			Age:      100,
			Password: "123456",
		}
		//userMap := map[string]string{
		//	"username": "xxx",
		//	"age":      "100",
		//	"password": "123456",
		//}
		context.JSON(200, user)
		context.JSON(200, gin.H{"username": "xxx", "age": 100})
	})

	router.GET("/html", _html)
	router.Run(":8080")
}
